package com.srit.system.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.srit.forecast.constant.Constant;
import com.srit.system.bean.Grid;
import com.srit.system.bean.GridAttrRel;
import com.srit.system.bean.GridAttribute;
import com.srit.system.bean.PageConfig;
import com.srit.system.constant.SystemConstant;
import com.srit.system.dao.PageConfigDao;

/**
 * 报文页面构建类
 * 
 * @author guan
 * 
 */
@Controller
public class GridViewController {
	@Autowired
	private PageConfigDao pageConfigDao;

	@RequestMapping(value = "/gridView")
	public String renderReport(@RequestParam int id, ModelMap modelMap) {
		PageConfig pageConfig = pageConfigDao.getById(id);
		// reportConfig.(2);
		GridAttribute attr = new GridAttribute();
		attr.setShowType(Constant.GRID_ATTR_SELECT);
		attr.setCodeType("WIND");
		List<GridAttrRel> relList = new ArrayList<GridAttrRel>();
		for (int i = 0; i < 2; i++) {
			GridAttrRel rel = new GridAttrRel();
			rel.setHtmlId("th_time");
			rel.setHtmlName("th_time");
			rel.setShowName("测试");
			rel.setWidth("20%");
			rel.setTitle("测试啊测试啊");
			relList.add(rel);
		}

		List<Grid> gridList = new ArrayList<Grid>();
		Grid grid = new Grid();
		grid.setEffectTime(2);
		grid.setRelList(relList);
		gridList.add(grid);

		pageConfig.setGridList(gridList);

		// reportConfig.setRelList(relList);
		modelMap.addAttribute(SystemConstant.PAGECONFIG, pageConfig);
		return pageConfig.getPageValue();
	}
}
